const router = require('koa-router')();
const Index = require("../controllers/index")
const App = require("../controllers/app");
const moment = require("moment")
const multer = require('koa-multer');//加载koa-multer模块  
//渲染主页
router.get('/', Index.showIndex)
router.get('/index',Index.showIndex);
router.get('/index/:type', Index.showIndex)
//详情页
router.get('/detail/:id',Index.showDetail)
//配置  上传图片
router.post('/upload',multer({ storage: App.storage }).any('avatar'),Index.upload)
//评论
router.post("/comment",App.verifyToken,App.hasBody,Index.comment);
//获取当前文章的所有评论
router.get("/commentList",Index.getComentList);
//修改个人信息
router.get("/myinfo",Index.showInfo);
//头像上传
router.post("/headupload",App.hasBody,Index.uploadHead);
//个人信息
router.post("/userInfo",App.hasBody,Index.saveUserInfo);
module.exports = router
